
<?
include('../config.php');

$cid = $_REQUEST['departmentid'];

$form = new form();
$form->table = "departments";
$form->action = "HandleSubmit.php";
$form->include = array("department"=>"name","description"=>"description");


if(!$cid){
	$form->title 		= "Add new department";
	$form->submit 		= "Add department";
}else{
	$form->title 		= "Edit department";
	$form->submit 		= "Edit department";
	$form->index 		= $cid;
	$form->indexname	= "departmentid";
	$form->Addnew		= array('url'=>'departments.php','text'=>'Add New department');
}
$parse = $form->CreateForm();
echo $parse;

$view = new view();
//creating the view
$view->title 						= "Current defined departments";
$view->query 						= "select departmentid, name,description from ".$form->table;
$view->properties['headers'] 		= array('department ID'=>"",'department '=>"","description"=>"");
$view->properties['style']		= "tablesorter";
$view->properties['cols']			= '5';
$view->properties['editurl']		= 'add-department.php';
$view->properties['editparam']  	= array('departmentid'=>'##departmentid##');
$view->properties['deleteurl']		= 'HandleSubmit.php';
$view->properties['deleteparam']	= array('index'=>'##departmentid##','indexname'=>'departmentid','submit'=>'DELETE','t'=>$form->table);
$parse = $view->CreateView();
echo $parse;
echo "<a href='index.php'>Home</a>";
?>